class P694{
	public static void main(String[] args){
		java.util.StringTokenizer entrada = new java.util.StringTokenizer(readLn());
		int a = Integer.parseInt(entrada.nextToken());
		int lim = Integer.parseInt(entrada.nextToken());
		int cont = 0;
		while (a >= 0 && lim >= 0) {
			cont++;
			System.out.println("Case "+cont+": A = "+a+", limit = "+lim+", number of terms = "+cycleLength(a, lim));
			entrada = new java.util.StringTokenizer(readLn());
			a = Integer.parseInt(entrada.nextToken());
			lim = Integer.parseInt(entrada.nextToken());
		}
	}
	
	private static int cycleLength(int a, int lim){
		int tamCiclo = 1;
		long numAtual = a;
		while (numAtual != 1 && numAtual <= lim) {
			numAtual = numAtual % 2 == 0 ? numAtual / 2 : 3 * numAtual + 1;
			tamCiclo++;
		}
		if (numAtual > lim)
			return tamCiclo - 1;
		return tamCiclo;
	}
	
	private static String newLine = System.getProperty("line.separator");

	static String readLn () {
	        StringBuffer buffer = new StringBuffer();
	        int car = -1;

        	try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char)car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}

		if ((car < 0) && (buffer.length() == 0))
			return (null);  /* eof */
		return (buffer.toString()).trim();
	}
}